import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
const store = new Vuex.Store({
    state: {
		token:'',
		openid:''
	},
	getters:{
		getToken(state){
			return state.token
		},
		getOpenid(state){
			return state.openid
		}
	},
    mutations: {
		setToken(state,payload){
			state.token=payload;
			uni.setStorageSync({key:'token',data:payload})
		},
		setOpenid(state,payload){
			state.openid=payload;
			uni.setStorageSync({key:'openid',data:payload})
		}
	},
    actions: {
		setToken(context,payload){
			  context.commit('setToken',payload)
		},
		setOpenid(context,payload){
			  context.commit('setOpenid',payload)
		}
	}
})
export default store